#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define N 1000100
using namespace std;

int nt[N];

void create_next(string& t)
{
    nt[0] = 0;
    int j = 0;
    for(int i = 1;i<t.size();++i)
    {
        while(j>0&&t[i]!=t[j])
        {
            j = nt[j-1];
        }
        if(t[i] == t[j])
        {
            j++;
        }
        nt[i] = j;
    }
}

void KMP(string& s1,string& s2)
{
    create_next(s2);
    int j = 0;
    for(int i = 0;i<s1.size();++i)
    {
        while(j>0&&s1[i]!=s2[j])
        {
            j = nt[j-1];
        }
        if(s1[i] == s2[j])
        {
            j++;
        }
        if(j == s2.size())
        {
            cout<<(i-j+2)<<endl;
            //j = 0;
        }
    }
}

void solve()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s2.size()<=s1.size())
    {
        KMP(s1,s2);
    }
    for(int i = 0;i<s2.size();++i)
    {
        cout<<nt[i]<<' ';
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    solve();
    return 0;
}
